package juc.c_012;/*
   Talk is cheap. Show me the code.
 */

/**
 * @Description 双重检查单例
 * @Date 2021/6/6
 * @Author liudl
 */
public class DCLSingleton {
    private static volatile DCLSingleton INSTANCE;
    private DCLSingleton() { }
    public DCLSingleton getInstance(){
        if (INSTANCE == null) {
            synchronized (DCLSingleton.class) {
                if (INSTANCE == null) {
                    return INSTANCE;
                } else {
                    INSTANCE = new DCLSingleton();
                }
            }
        }
        return INSTANCE;
    }

}
